/*
 * 本类作用：mina框架：IoFilterAdapter（上一步：mina启动StartServer，下一步：mina框架过滤器MinaServerIOHandler）
 * 
 * 作者：袁小杰
 * 博客：http://blog.csdn.net/undoner
 * GIT：https://git.oschina.net/undoner
 * QQ：15137281
 * 
 */
package org.mina.server;

import org.apache.log4j.Logger;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.filterchain.IoFilterChain;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.core.write.WriteRequest;

// 用于判断数据合法性
public class MinaServerIOFilter extends IoFilterAdapter {

	static Logger log = Logger.getRootLogger();

	public MinaServerIOFilter() {
		// TODO Auto-generated constructor stub
		log.debug(this.getClass().getName() + "：IOFilterFilter");
	}

	/**
	 * messageReceived，之后转到handler
	 * */
	public void messageReceived(NextFilter nextFilter, IoSession session,
			Object message) throws Exception {
	log.debug(this.getClass().getName() + "：messageReceived");
		//13862082455:117.13252:029.77606:146.5418
		nextFilter.messageReceived(session, message);
	}
	@Override

	public void destroy() throws Exception {

	log.debug(this.getClass().getName() +  "：destroy");

	}

	@Override

	public void exceptionCaught(NextFilter nextFilter, IoSession

	session,

	Throwable cause) throws Exception {

	log.debug(this.getClass().getName() + "：exceptionCaught");

	nextFilter.exceptionCaught(session, cause);

	}

	@Override

	public void filterClose(NextFilter nextFilter, IoSession session)

	throws Exception {

	log.debug(this.getClass().getName() + "：filterClose");

	nextFilter.filterClose(session);

	}

	@Override

	public void filterWrite(NextFilter nextFilter, IoSession session,

	WriteRequest writeRequest) throws Exception {

	log.debug(this.getClass().getName() + "：filterWrite");

	nextFilter.filterWrite(session, writeRequest);

	}

	@Override

	public void init() throws Exception {

	log.debug(this.getClass().getName() + "：init");

	}


	@Override

	public void messageSent(NextFilter nextFilter, IoSession session,

	WriteRequest writeRequest) throws Exception {

	log.debug(this.getClass().getName() + "：messageSent");

	nextFilter.messageSent(session, writeRequest);

	}

	@Override

	public void onPostAdd(IoFilterChain parent, String name,

	NextFilter nextFilter) throws Exception {

	log.debug(this.getClass().getName() + "：onPostAdd");

	}

	@Override

	public void onPostRemove(IoFilterChain parent, String name,

	NextFilter nextFilter) throws Exception {

	log.debug(this.getClass().getName() + "：onPostRemove");

	}

	@Override

	public void onPreAdd(IoFilterChain parent, String name,

	NextFilter nextFilter) throws Exception {

	log.debug(this.getClass().getName() + "：onPreAdd");

	}

	@Override

	public void onPreRemove(IoFilterChain parent, String name,

	NextFilter nextFilter) throws Exception {

	log.debug(this.getClass().getName() + "：onPreRemove");

	}

	@Override

	public void sessionClosed(NextFilter nextFilter, IoSession session)

	throws Exception {

	log.debug(this.getClass().getName() + "：sessionClosed");

	nextFilter.sessionClosed(session);

	}

	@Override

	public void sessionCreated(NextFilter nextFilter, IoSession session)

	throws Exception {

	log.debug(this.getClass().getName() + "：sessionCreated");

	nextFilter.sessionCreated(session);

	}

	@Override

	public void sessionIdle(NextFilter nextFilter, IoSession session,

	IdleStatus status) throws Exception {

	log.debug(this.getClass().getName() + "：sessionIdle");

	nextFilter.sessionIdle(session, status);

	}

	@Override

	public void sessionOpened(NextFilter nextFilter, IoSession session)

	throws Exception {

	log.debug(this.getClass().getName() + "：sessionOpened");

	nextFilter.sessionOpened(session);

	}


}
